import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;


public class Player {
	int playerWidth, playerHeight;
	private Rectangle bb;
	Point2D.Double ctr,vel;

	public Player(Point2D.Double startCenter, int playerWidth, int playerHeight, Point2D.Double vel){

		//Make sure to clone, we dont want the references, we just want the data.
		ctr = (Double) startCenter.clone();
		this.playerWidth = playerWidth;
		this.playerHeight = playerHeight;
		this.vel = (Double) vel.clone();
		
		bb = new Rectangle(
				(int)Math.round(ctr.x - playerWidth/2.0),
				(int)Math.round(ctr.y - playerHeight/2.0),
				playerWidth, playerHeight	);
		
	}

	//For future work, maybe don't update the position of bb every frame but rather
	//only when we require checking collisions with tiles.
	public void moveCenterTo(double px, double py){
		
		double dx =  px - bb.getCenterX();
		double dy =  py - bb.getCenterY();
		
		
		//Update player rect every time
		bb.setLocation((int)Math.round( bb.getX() + dx), (int)Math.round( bb.getY()+dy));
		
		ctr.x = px;
		ctr.y = py;
	}

	//Draws the player with the point 'ctr' as the center
	public void drawSelf(Graphics2D g2){
		Color old = g2.getColor();
		g2.setColor(new Color(.25f, .25f, .25f, .75f));
		g2.fill(bb);
		g2.setColor(old);

	}
	public Rectangle getRect(){
		return bb;
	}

}
